Index



Overview


This section is all about common Java examples. Things like getter and setters, implementing equals, etc.

Mutable and Immutable


Mutable: Changeable
Immutable: Non-Chageable

Why would we want an immutable object?

Let's think about Java String and consider an employee object. If String was mutable (changeable), a client object could take a Student object and ask for it's name and change it's name! "Mary" could be come "Larry"! 😢. However, Java's String class is immutable so no such worries.

A couple advantages of immutable classes:

So just another tool for our toolbox to use where it fits.